package com.lkj.controller;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.lkj.entity.SysDept;
import com.lkj.service.SysDeptService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 部门表(SysDept)表控制层
 *
 * @author makejava
 * @since 2020-09-13 10:39:01
 */
@RestController
@RequestMapping("/sysDept")
public class SysDeptController {
    /**
     * 服务对象
     */
    @Resource
    private SysDeptService sysDeptService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping(value = "/selectOne")
    public String selectOne(Long id) {

        SysDept sysDept = this.sysDeptService.queryById(id);

        System.out.println(sysDept);


        return JSONUtil.toJsonStr(sysDept);
    }


    @GetMapping(value = "/selectUserListByDeptId")
    public String selectUserListByDeptId(Long id){

        List<SysDept> sysDept = sysDeptService.selectUserListByDeptId(id);

        System.out.println(sysDept);

        String s = JSONUtil.toJsonStr(sysDept);

        System.out.println(s);

        return s;

    }

}